package com.study.controller;

import com.study.pojo.Emp;
import com.study.pojo.EmpQueryParam;
import com.study.pojo.PageResult;
import com.study.pojo.Result;
import com.study.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/emps")
public class EmpController {
    @Autowired
    EmpService empService;
    /*
    * 查询员工信息
    */
    @GetMapping
    public Result page(EmpQueryParam empQueryParam){
        log.info("分页请求参数{}",empQueryParam);
        PageResult<Emp> pageResult = empService.page(empQueryParam);
        return Result.success(pageResult);
    }
    /*
    *添加员工
    */
    @PostMapping
    public Result save(@RequestBody Emp emp){
        log.info("新增的员工信息{}",emp);
        empService.save(emp);
        return Result.success();
    }
}
